import { Node, Size, UITransform, Vec2, Vec3, v2 } from "cc";

class Display {
    /**屏幕尺寸 */
    public size: Size;
    /** 屏幕宽 */
    public width: number;
    /** 屏幕高 */
    public height: number;
    /** 中心x/宽的一半 */
    public cx: number;
    /** 中心y/高的一半 */
    public cy: number;
    /** 中心点 */
    public center: Vec2;

    public SCA_0: Readonly<Vec3> = new Vec3(0, 0, 0);
    public SCA_1: Readonly<Vec3> = new Vec3(1, 1, 1);
    public POS_0: Readonly<Vec3> = new Vec3(0, 0, 0);

    private is_init: boolean = false;
    public init(scene_node: Node){
        if(this.is_init)  return;

        this.size = scene_node.getComponent(UITransform).contentSize;
        this.width = this.size.width;
        this.height = this.size.height;
        this.cx = this.width / 2;
        this.cy = this.height / 2;
        this.center = v2(this.cx, this.cy);
    }
}
/** 设备参数相关 */
export const display = new Display();